export function download(res: any, fileName: string) {
  if (!res) {
    return false;
  }
  const blob = new Blob([res], {
    type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8',
  });
  const a = document.createElement('a');
  const href = window.URL.createObjectURL(blob);
  let filename = decodeURI(fileName);
  a.style.display = 'none';
  a.href = href;
  a.download = filename;
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
  window.URL.revokeObjectURL(href);
}

export function downloadWithUrl(href: string, fileName: string) {
  const a = document.createElement('a');

  let filename = decodeURI(fileName);
  a.style.display = 'none';
  a.href = href;
  a.download = filename;
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
}
